/// Support for doing something awesome.
///
/// More dartdocs go here.
library;

import 'package:base_expressions/base_expressions.dart';

export 'src/base_expressions_base.dart';

// TODO: Export any libraries intended for clients of this package.
late String description;

void main() {
  final name = 'Bob'; // Without a type annotation
  final String nickname = 'Bobby';
  const bar = 1000000; // Unit of pressure (dynes/cm2)
  const double atm = 1.01325 * bar; // Standard atmosphere

  description = 'Feijoada!';
  print(description);

  assert(2 + 3 == 5, '2 + 3 不等于 5');
  assert(2 - 3 == -1, '2 - 3 不等于 -1');
  assert(2 * 3 == 6, '2 * 3 不等于 6');
  assert(5 / 2 == 2.5, '5 / 2 不等于 2.5'); // Result is a double

  int a;
  int b;

  a = 0;
  b = ++a; // Increment a before b gets its value.
  assert(a == b); // 1 == 1
  
  a = 0;
  b = a++; // Increment a after b gets its value.
  assert(a != b); // 1 != 0
  
  a = 0;
  b = --a; // Decrement a before b gets its value.
  assert(a == b); // -1 == -1
  
  a = 0;
  b = a--; // Decrement a after b gets its value.
  assert(a != b); // -1 != 0

  Employee employee = Employee('Alice', 'E001');
  
  // 将 employee 对象强制转换为 Person 类型，并修改 firstName 属性
  (employee as Person).firstName = 'Bob';
  
  print(employee.firstName); // 输出: Bob

  var f = 2; // Assign using =
  f *= 3; // Assign and multiply: f = f * 3
  assert(f == 6);

  bool isPublic=true;
  var visibility = isPublic ? 'public' : 'private';
  print(visibility);

  var person = aPerson()
    ..name = 'John'
    ..age = 30
    ..email = 'john@example.com';

  // 可空对象级联操作
  Address? nullableAddress;
  nullableAddress?..street = '456 Elm St'
      ..city = 'Othertown'
      ..zipCode = '67890';

  // 级联嵌套操作
  person..address = (Address()
        ..street = '123 Main St'
        ..city = 'Anytown'
        ..zipCode = '12345');

  person.printInfo();
}